import request from '@/router/axios';

export const getList = (current, size, params, type) => {
  return request({
    url: `/api/mes-warehouse/sheetheader/page`, //sheetTypeStrList
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

//备料单单独分页接口
export const getPreparationList = (current, size, params, type) => {
  return request({
    url: `/api/mes-warehouse//sheetheader/preparation-page`,
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// export const getDetail = (id) => {
//   return request({
//     url: '/api/mes-warehouse/sheetheader/detail',
//     method: 'get',
//     params: {
//       id
//     }
//   })
// }

export const getDetail = (id) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-detail/list-with-part-master',
    method: 'get',
    params: {
      sheetHeaderId: id
    }
  });
};
export const getDetailTo = (id) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-detail/list-with-part-master',
    method: 'get',
    params: {
      sheetHeaderIdList: id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/submit',
    method: 'post',
    data: row
  });
};

//领料单 退料单
export const getSheetDetail = (params) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-detail/list-with-bom',
    method: 'get',
    params
  });
};

/**
 * 包装详情
 */

export const getPackId = (params) => {
  return request({
    url: '/api/mes-warehouse/packing/list',
    method: 'get',
    params
  });
};

/**
 * 获取替代料
 */
export const getReplacePart = (params) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-detail/list-with-bom-replacement',
    method: 'get',
    params
  })
}

/**
 * 获取备料单
 */
export const getSheetPartList = (action, sheetIdList) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/merging',
    method: 'post',
    data: {
      action,
      sheetIdList
    }
  });
};

export const submitPreparation = (row) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/submit-batch',
    method: 'post',
    data: row
  });
};

/**
 *  盘点单物料包装详情
 */
export const getAoPackId = (params) => {
  return request({
    url: '/api/mes-warehouse/packing/detail-packing-list',
    method: 'get',
    params
  });
};

/**
 * 获取生产退料包装详情
 */

export const getMaterialPackId = (params) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-packing/list-of-pack-by-sheet',
    method: 'get',
    params
  });
};

export const getSheetNoPack = (id) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/pack-list-of-sheet',
    method: 'get',
    params: {
      sheetId: id
    }
  });
};

export const getPackInfo = (sheetDetailId, sheetHeaderId) => {
  return request({
    url: '/api/mes-warehouse/sheetheader/sheet-packing/list-of-pack-by-sheet',
    method: 'get',
    params: {
      sheetDetailId: sheetDetailId,
      sheetHeaderId: sheetHeaderId
    }
  });
};

export const getSheetPackInfo = (params) => {
  return request({
    url: '/api/mes-warehouse/receiving/packing-tree-by-headerId',
    method: 'get',
    params
  });
};

